﻿CREATE PROCEDURE [dbo].[smenu_TrackerRequest_Transaction]
(	@TrackerRequestID int,
	@TransactionTypeID int -- 1-Installed,2-Removeed
)AS
SET NOCOUNT ON

IF @TransactionTypeID = 1
INSERT INTO t_TrackerTransaction(TypeID,TrackerRequestID,Amount,StatusID,TrackerID)
SELECT @TransactionTypeID TypeID,@TrackerRequestID,ttt.Amount,98,tc.TrackerID
FROM ts_TrackerTransactionType ttt
CROSS JOIN t_Tracker_Car tc
WHERE ttt.ID = @TransactionTypeID AND tc.TrackerRequestID = @TrackerRequestID

IF @TransactionTypeID = 2
INSERT INTO t_TrackerTransaction(TypeID,TrackerRequestID,Amount,StatusID,TrackerID)
SELECT @TransactionTypeID TypeID,@TrackerRequestID,ttt.Amount,98,tt.TrackerID
FROM ts_TrackerTransactionType ttt
CROSS JOIN t_Technician_Tracker tt
WHERE ttt.ID = @TransactionTypeID AND tt.TrackerRequestID = @TrackerRequestID



